home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / pyshared / UbuntuSystemService / utils.py
Text File  |  2009-10-15  |  643b  |  27 lines

  1. import re
  2.  
  3. def verify_proxy(proxy_type, proxy):
  4.     """
  5.     This verifies a proxy string. It works by whitelisting
  6.     certain charackters: 0-9a-zA-Z:/?=-;~+
  7.     """
  8.     # protocol://host:port/stuff
  9.     verify_str = "%s://[a-zA-Z0-9.-]+:[0-9]+/*$" % proxy_type
  10.  
  11.     if not re.match(verify_str, proxy):
  12.             return False
  13.     return True
  14.  
  15. def verify_no_proxy(proxy):
  16.     """
  17.     This verifies a proxy string. It works by whitelisting
  18.     certain charackters: 0-9a-zA-Z:/?=-;~+
  19.     """
  20.     # protocol://host:port/stuff
  21.     verify_str = "[a-zA-Z0-9.-:,]+" 
  22.  
  23.     if not re.match(verify_str, proxy):
  24.             return False
  25.     return True
  26.  
  27.